package 代码记录.指定公司代码练习记录.西安.分值200分.分支200分未做;

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author zx
 * @create 2023-07-11 21:07
 */
public class 解压报文 {
    public static final Pattern only = Pattern.compile("[0-9]+\\[[a-z]+]");
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        System.out.print(solveMethod(str));
    }
    public static String solveMethod(String str) {
        if (str == null || "".equals(str))
            return "";
        Matcher matcher = only.matcher(str);
        if (!matcher.find()) {
            return str;
        }
        String group = matcher.group();
        int pos = group.indexOf('[');
        int counts = Integer.parseInt(group.substring(0, pos));
        String words = group.substring(pos + 1, group.length() - 1);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < counts; ++i) {
            sb.append(words);
        }
        String res = str.replace(group, sb.toString());
        return solveMethod(res);
    }
}
